<!DOCTYPE html>
<html>
  <head>
    <meta charset='utf-8'>
    <meta content='width=device-width, initial-scale=1.0' name='viewport'>
    <meta content='' name='description'>
    <meta content='Nils Nordman' name='author'>
    <link href='/images/howl.png' rel='shortcut icon'>
    <title>Howl :: howl.Application</title>
    <link href="/stylesheets/bootstrap.min.css" media="screen" rel="stylesheet" type="text/css" />
    <link href="/stylesheets/syntax.css" media="screen" rel="stylesheet" type="text/css" />
    <link href="/stylesheets/howl.css" media="screen" rel="stylesheet" type="text/css" />
    <script src="https://code.jquery.com/jquery-1.12.3.min.js" type="text/javascript"></script>
    <script src="/javascripts/bootstrap.min.js" type="text/javascript"></script>
    
    <link href='//fonts.googleapis.com/css?family=Josefin+Slab' rel='stylesheet' type='text/css'>
    <link href='//fonts.googleapis.com/css?family=Open+Sans+Condensed:700' rel='stylesheet' type='text/css'>
  </head>
  <body class='doc doc_api doc_api_application'>
    <div class='container'>
      <div class='masthead'>
        <ul class='nav nav-pills'>
          <li>
            <a href='/'>
              <span class='glyphicon glyphicon-home'></span>
              Home
            </a>
          </li>
          <li>
            <a href='/doc/'>
              <span class='glyphicon glyphicon-book'></span>
              Documentation
            </a>
          </li>
          <li>
            <a href='/blog/'>
              <span class='glyphicon glyphicon-bullhorn'></span>
              Blog
            </a>
          </li>
          <li>
            <a href='/contact.html'>
              <span class='glyphicon glyphicon-inbox'></span>
              Contact
            </a>
          </li>
        </ul>
      </div>
      <ol class="breadcrumb"><li><a href="/">Home</a></li><li><a href='../'>Howl 0.4 Documentation</a></li><li>Api</li><li>howl.Application</li></ol>
      <h1 id="howl.application">howl.Application</h1>    <div class="toc">
      <div class="toc-title">
        <span>howl.Application</span>
      </div>
      <div class="toc-entries">
<div class="toc-group">
<a href="#properties" class="toc-group-header properties">Properties</a>
<li class=""><a href="#buffers">buffers</a></li>
<li class=""><a href="#editor">editor</a></li>
<li class=""><a href="#editors">editors</a></li>
<li class=""><a href="#idle">idle</a></li>
<li class=""><a href="#next_buffer">next_buffer</a></li>
<li class=""><a href="#window">window</a></li>
<li class=""><a href="#windows">windows</a></li>
</div>
<div class="toc-group">
<a href="#methods" class="toc-group-header methods">Methods</a>
<li class=""><a href="#add_buffer">add_buffer </a></li>
<li class=""><a href="#close_buffer">close_buffer </a></li>
<li class=""><a href="#editor_for_buffer">editor_for_buffer </a></li>
<li class=""><a href="#new_buffer">new_buffer </a></li>
<li class=""><a href="#new_editor">new_editor </a></li>
<li class=""><a href="#new_window">new_window </a></li>
<li class=""><a href="#open_file">open_file </a></li>
<li class=""><a href="#save_all">save_all </a></li>
<li class=""><a href="#save_session">save_session </a></li>
<li class=""><a href="#synchronize">synchronize </a></li>
<li class=""><a href="#quit">quit </a></li>
</div>
</div>
</div>
&#x000A;&#x000A;<p>The Application object acts as the main hub within the Howl editor. There exists&#x000A;one and only one instantiated application object per Howl instance, available as&#x000A;<code>howl.app</code>.</p>&#x000A;&#x000A;<h2 id="properties">Properties</h2>&#x000A;&#x000A;<h3 id="buffers">buffers</h3>&#x000A;&#x000A;<p>A list of currently open <a href="buffer.html">Buffer</a>:s. The list is ordered by how recently a&#x000A;buffer was shown. Thus, a currently showing buffer will come before a buffer&#x000A;that is not shown, and  not showing buffers will be ordered according to the&#x000A;timestamp they were last shown.</p>&#x000A;&#x000A;<h3 id="editor">editor</h3>&#x000A;&#x000A;<p>Points to the currently active <a href="ui/editor.html">Editor</a>, if any.</p>&#x000A;&#x000A;<h3 id="editors">editors</h3>&#x000A;&#x000A;<p>A list of all existing <a href="ui/editor.html">Editor</a>:s. Each editor can be placed in only one window&#x000A;at a time, but this list holds all editors present for the current Howl instance&#x000A;- regardless of whether they&rsquo;re placed in the currently focused window or not.</p>&#x000A;&#x000A;<h3 id="idle">idle</h3>&#x000A;&#x000A;<p>A number providing information on how long the application has been idle, in&#x000A;seconds (with fractions). As the idle is reset upon activity this is useful&#x000A;primarily in timers and idle callbacks.</p>&#x000A;&#x000A;<h3 id="next_buffer">next_buffer</h3>&#x000A;&#x000A;<p>This is the most recent buffer that is currently not showing in any editor. If&#x000A;all buffers are currently showing it&rsquo;s the first buffer in <a href="#.buffers">.buffers</a>.</p>&#x000A;&#x000A;<h3 id="window">window</h3>&#x000A;&#x000A;<p>Points to the currently focused <a href="ui/window.html">Window</a>.</p>&#x000A;&#x000A;<h3 id="windows">windows</h3>&#x000A;&#x000A;<p>A list of existing <a href="ui/window.html">Window</a>:s.</p>&#x000A;&#x000A;<h2 id="methods">Methods</h2>&#x000A;&#x000A;<h3 id="add_buffer">add_buffer <span class="arg-list">(buffer, show = true)</span></h3>&#x000A;&#x000A;<p>Adds the existing <code>buffer</code> to <a href="#.buffers">.buffers</a>. If <code>show</code> is true, shows the buffer in&#x000A;the currently active editor.</p>&#x000A;&#x000A;<h3 id="close_buffer">close_buffer <span class="arg-list">(buffer, force = false)</span></h3>&#x000A;&#x000A;<p>Removes <code>buffer</code> from <a href="#.buffers">.buffers</a>. If the buffer is modified, and <code>force</code> is not&#x000A;true, the user  is prompted before closing the buffer.</p>&#x000A;&#x000A;<h3 id="editor_for_buffer">editor_for_buffer <span class="arg-list">(buffer)</span></h3>&#x000A;&#x000A;<p>Returns the editor currently showing <code>buffer</code>, or <code>nil</code> if the buffer is not&#x000A;currently showing in any editor.</p>&#x000A;&#x000A;<h3 id="new_buffer">new_buffer <span class="arg-list">(buffer_mode = nil)</span></h3>&#x000A;&#x000A;<p>Creates a new buffer, and adds it to <a href="#.buffers">.buffers</a>. <code>buffer_mode</code> can optionally be&#x000A;specified to assign a specific mode for the new buffer directly. When not&#x000A;specified, the <a href="modes/default_mode.html">default mode</a> is used. See <a href="mode.html">mode</a> for more information about&#x000A;buffer modes.</p>&#x000A;&#x000A;<h3 id="new_editor">new_editor <span class="arg-list">(options = {})</span></h3>&#x000A;&#x000A;<p>Creates a new <a href="ui/editor.html">Editor</a>. Unless <code>options</code> specify otherwise, the newly created&#x000A;editor is added to the currently focused window, to the right of the currently&#x000A;focused existing editor. It&rsquo;s set to show the buffer from the <a href="#.next_buffer">.next_buffer</a>&#x000A;property. The editor is added to <a href="#.editors">.editors</a> before the return of the method.</p>&#x000A;&#x000A;<p><code>options</code> can contain any of the following keys:</p>&#x000A;&#x000A;<ul>&#x000A;<li><em>buffer</em>: The buffer that should be shown in the editor. Defaults to <a href="#.next_buffer">.next_buffer</a>.</li>&#x000A;<li><em>window</em>: The window to add the editor to. Defaults to the currently focused window.</li>&#x000A;<li><em>placement</em>: How the new editor should be placed in the target window. See&#x000A;<a href="ui/window.html#add_view">Window.add_view</a> for more information about possible&#x000A;placement values.</li>&#x000A;</ul>&#x000A;&#x000A;<h4 id="example-use-(moonscript):">Example use (Moonscript):</h4>&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">howl</span><span class="p">.</span><span class="n">app</span><span class="o">\</span><span class="n">new_buffer</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'Show this text in the new buffer'</span><span class="w">&#x000A;</span><span class="n">howl</span><span class="p">.</span><span class="n">app</span><span class="o">\</span><span class="n">new_editor</span><span class="w"> </span><span class="ss">:buffer</span><span class="w">&#x000A;</span></pre>&#x000A;<h3 id="new_window">new_window <span class="arg-list">(properties = {})</span></h3>&#x000A;&#x000A;<p>Creates a new application <a href="ui/window.html">Window</a>. <code>properties</code> is table of window properties&#x000A;to set for the new window, such as title, height and width. The window is added&#x000A;to <a href="#.windows">.windows</a> before the return of the method. Returns the newly created window.</p>&#x000A;&#x000A;<h3 id="open_file">open_file <span class="arg-list">(file, editor = _G.editor)</span></h3>&#x000A;&#x000A;<p>Opens the provided <a href="fs/file.html">file</a>. By default, unless <code>editor</code> specifies a&#x000A;specific editor to open the file into, the file is opened in the currently&#x000A;active editor. Emits the <code>file-opened</code> signal if the file was opened&#x000A;successfully. If the file was successfully opened, returns the <a href="buffer.html">Buffer</a> and the&#x000A;<a href="ui/editor.html">Editor</a> holding the buffer. Otherwise <code>nil</code> is returned.</p>&#x000A;&#x000A;<h3 id="save_all">save_all <span class="arg-list">()</span></h3>&#x000A;&#x000A;<p>Saves all modified buffers in one go.</p>&#x000A;&#x000A;<h3 id="save_session">save_session <span class="arg-list">()</span></h3>&#x000A;&#x000A;<p>Saves the current editing session to disk. This includes things such as&#x000A;information about what buffers are open, the current state of the window, etc.</p>&#x000A;&#x000A;<h3 id="synchronize">synchronize <span class="arg-list">()</span></h3>&#x000A;&#x000A;<p>Synchronizes all open files with their respective files, if any. This will cause&#x000A;any non-modified buffers to be reloaded from disk, should the file be more&#x000A;recently modified than the buffer.</p>&#x000A;&#x000A;<h3 id="quit">quit <span class="arg-list">(force = false)</span></h3>&#x000A;&#x000A;<p>Requests for Howl to quit. If any open buffers are modified, and <code>force</code> is not&#x000A;true, the user will be prompted for verification before actually quitting.</p>
      <div class='footer text-muted'>
        <a href='/'>
          <img width="50" height="50" class="footer-logo" src="/images/howl.png" />
        </a>
        <div class='footer-follow'>
          <p>
            <a class='twitter-follow-button' data-lang='en' data-show-count='false' href='https://twitter.com/howleditor' rel='me'>
              Follow @howleditor
            </a>
          </p>
          <p>
            <a class='twitter-share-button' data-count='none' data-hashtags='howleditor' data-lang='en' data-text='The Howl Editor, a general purpose, light-weight customizable editor.' data-url='http://howl.io' href='https://twitter.com/share'>
              Tweet
            </a>
          </p>
        </div>
        <div class='footer-blurb'>
          <div>The Howl editor.</div>
          <div>
            Copyright 2012-2016
            <a class='alert-link' href='https://github.com/howl-editor/howl/contributors'>
              The Howl Developers.
            </a>
          </div>
        </div>
      </div>
    </div>
    <script>
      <!-- / GA -->
      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
      ga('create', 'UA-45283282-1', 'howl.io');
      ga('send', 'pageview');
      <!-- / Twitter -->
      !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];
      if(!d.getElementById(id)){js=d.createElement(s);js.id=id;
      js.src="//platform.twitter.com/widgets.js";
      fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
    </script>
  </body>
</html>
